﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_Letter : ServerBasePacket
    {
        private static Logger _log = Logger.getLogger( typeof( S_Letter ).FullName );

        private byte[] _byte = null;

        public S_Letter( L1ItemInstance item )
        {
            buildPacket( item );
        }

        private void buildPacket( L1ItemInstance item )
        {
            /*
             * Connection con = null; PreparedStatement pstm = null; ResultSet rs = null;
             * try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con
             * .prepareStatement("SELECT * FROM letter WHERE item_object_id=?");
             * pstm.setInt(1, item.getId()); rs = pstm.executeQuery(); while (rs.next()) {
             * writeC(Opcodes.S_OPCODE_LETTER); writeD(item.getId()); if (item.get_gfxid() ==
             * 465) { // 開く前 writeH(466); // 開いた後 } else if (item.get_gfxid() == 606) {
             * writeH(605); } else if (item.get_gfxid() == 616) { writeH(615); } else {
             * writeH(item.get_gfxid()); } writeH(rs.getInt(2)); writeS(rs.getString(3));
             * writeS(rs.getString(4)); writeByte(rs.getBytes(7));
             * writeByte(rs.getBytes(8)); writeC(rs.getInt(6)); // テンプレ
             * writeS(rs.getString(5)); // 日付 } } catch (SQLException e) {
             * _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally {
             * SQLUtil.close(rs); SQLUtil.close(pstm); SQLUtil.close(con); }
             */
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_Letter";
        }
    }
}